package com.sanyu.lovefishing.mvp;

import com.lyf.core.presenter.BasePresenter;
import com.lyf.core.rx.BaseSubscriber;
import com.sanyu.lovefishing.AppConstant;
import com.sanyu.lovefishing.bean.WeatherBean;
import com.sanyu.lovefishing.data.ApiFactory;
import com.sanyu.lovefishing.mvp.view.IWeatherView;

import io.reactivex.rxjava3.annotations.NonNull;

public class WeatherPresenter extends BasePresenter<IWeatherView> {

    /**
     * 获取今日天气
     */
    public void getTodayWeather(){
        getView().showLoading();
        ApiFactory.getInstance().getApiRepository()
                .getTodayWeather(40.34,10.99, AppConstant.WEATHER_APPID)
                .compose(getLifecycleProvider())
                .safeSubscribe(new BaseSubscriber<WeatherBean>(getView()) {
                    @Override
                    public void onNext(@NonNull WeatherBean weatherBean) {
                        getView().showMessage(weatherBean.getId()+"");
                    }
                });
    }

}
